<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/html">
<head>

    <th:block th:include="MainInterface/include :: common-css" />

</head>
<body class="fixed-left">

    <div id="wrapper">
        <th:block th:include="MainInterface/include :: header-menu(1)" />

        <form id="bookList">
            <div class="dialog">
                <div class="dialog-box">
                    <h1>编辑书籍</h1>
                <p >
                    ID : <input  name="id" th:value="${booksList.id}" readonly unselectable="on">
                </p>
                <p>书籍号 : <input name="bookNo" th:value="${booksList.bookNo}"></p>
                <p>书籍名称 : <input name="bookName" th:value="${booksList.bookName}"></p>
                <p>
                    书籍状态 :
                        <select name="bookStatus">
                            <option th:each="statusList:${statusList}"
                                    th:value="${statusList.id}"
                                    th:selected="${booksList.bookStatus eq statusList.id}"
                                    th:text="${statusList.statusName}">已借完</option>

                        </select>
                </p>
                <p>书籍类型 :
                        <select name="bookType">
                            <option th:each="categroyList:${categroyList}"
                                    th:value="${categroyList.id}"
                                    th:selected="${booksList.bookType eq categroyList.id}"
                                    th:text="${categroyList.cateName}">科幻</option>
                        </select>
                </p>
                <p>
                    作者 :
                    <input name="bookAuthor" th:value="${booksList.bookAuthor}">
                </p>
                <p>
                    书籍数量 :
                    <input name="bookCount" th:value="${booksList.bookCount}">
                </p>
                <p>
                    出版社 :
                        <select name="publisher" >
                            <option th:each="publisherList:${publisherList}"
                                    th:value="${publisherList.id}"
                                    th:selected="${booksList.publisher eq publisherList.id}"
                                    th:text="${publisherList.name}"
                            >北京出版社</option>
                        </select>
                </p>
                <p>
                    出版时间 :
                    <input  type="date" name="pressDate" th:value="${booksList.pressDate}">
                </p>
                <div>
<!--                    <button style="width: 75px ; height : 50px"><a onclick="bookSave()">修改</a></button>-->
                    <input style="width: 75px ; height : 50px " type="button" value="修改" onclick="bookSave()">
                <!--            <button id="book_save" >提交</button>-->
                    <button style="width: 75px ; height : 50px"><a href="/books">返回</a></button>

                </div>
                </div>
            </div>

        </form>
    </div>

    <th:block th:include="MainInterface/include :: foter" />
    <th:block th:include="MainInterface/include :: common-js" />
</body>

<script>
    function bookSave(){

            $.ajax({
                type:"post",
                url:"/books/saveOrUpdata",
                data:$("#bookList").serialize(),
                async:false,
                dataType: 'json',
                success:function (result) {
                    if(result.code==0){
                        window.alert("修改成功");
                        window.location.href="/books"
                    } else {
                        window.alert(result.msg || "修改失败");
                    }

                }
            });

    }
</script>

</html>